package com.zjpavt.client.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 每天零点发布当天的离线指令跟当天定时器指令
 *
 * @author gxy
 */
public class DailyJob implements Job {

    private static final Logger log = LoggerFactory.getLogger(DailyJob.class);

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        switch (jobExecutionContext.getJobDetail().getJobDataMap().getString("TYPE")) {
        case JobManager.DAILY_JOB_TYPE_REFRESH_OFFLINE_COMMAND: {
            log.trace("time to execute offline command");
            JobRunner.getInstance().sendOfflineCommandOfToday();
            break;
        }
        case JobManager.DAILY_JOB_TYPE_REFRESH_TODAY_TIMER_COMMAND: {
            log.trace("time to execute today command");
            JobRunner.getInstance().sendTodayTimerCommand();
            break;
        }
        default:
            break;
        }
    }
}
